/**
 * Created by 준영 on 14. 3. 28.
 */
var mongo = require('mongodb');

var mongoClient = mongo.MongoClient;

var async = require('async');

exports.connect = function (url,callback) {
  getMongoDB(url, function (err, connectedDatabase) {
    if (err) {
      console.log(err);
      callback(err, null);
    }
    else {
      var db = new Database(connectedDatabase)
      callback(err, db)
    }
  });
};

function getMongoDB(url, callback) {
  mongoClient.connect(url, function(err, db) {
    if (err) {
      callback(err, null);
    } else {
      callback(err, db);
    }
  });
};

var Database = (function(){

  function Database(db){
    this.db = db;

  };
  return Database;
})();
